package com.xhji.web.mvc.exception;

import com.xhji.common.vo.ResultCode;

import java.util.Optional;


public class AbstractException extends RuntimeException {
    private int code;
    private String msg;

    public AbstractException(ResultCode errors, String message, Throwable throwable) {
        this(errors.getCode(), Optional.ofNullable(errors.getMessage()).orElse(message), throwable);
    }

    public AbstractException(ResultCode errors, String message) {
        this(errors, message, null);
    }

    public AbstractException(ResultCode errors) {
        this(errors, null, null);
    }

    public AbstractException(int code, String message, Throwable throwable) {
        super(throwable);
        this.code = code;
        this.msg = message;
    }

    public AbstractException() {
        super();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return msg;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
